package com.example.armmvvm.ui.customdraw.view

import android.content.Context
import android.graphics.*
import android.graphics.Paint.ANTI_ALIAS_FLAG
import android.util.AttributeSet
import android.view.View
import com.example.arm.ext.dp

/**
 * 绘制Path的方向Path.Direction的区别
 *
 * @author 创建人 ：yanghaozhang
 * @version 1.0
 * @package 包名 ：com.example.armmvvm.ui.main
 * @createTime 创建时间 ：2021/9/13
 * @modifyBy 修改人 ：
 * @modifyTime 修改时间 ：
 * @modifyMemo 修改备注：
 */
class CWWTestView(context: Context?, attrs: AttributeSet?) : View(context, attrs) {

    private val paint = Paint(ANTI_ALIAS_FLAG)

    private val rectF = RectF(0f, 0f, 200.dp, 200.dp)

    val path = Path()

    init {
        path.addRect(50.dp, 50.dp, 100.dp, 100.dp, Path.Direction.CCW)
        path.addOval(75.dp, 75.dp, 125.dp, 125.dp, Path.Direction.CW)
        path.fillType = Path.FillType.INVERSE_WINDING
    }

    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)
        paint.color = Color.RED
        canvas.drawPath(path, paint)
    }
}